<?php
namespace app\admin\controller;
use app\Base;
use think\facade\Db;
use think\facade\Filesystem;

class Files extends Base{
	
	private $site;
	protected function initialize()
    {
		$site=Db::name('site')->where("siteid",1)->find();
		$this->site=$site['domain'].$site['path'];
	}
	
	public function index()
    {
		
    }
	
    public function img()
    {
		$file = request()->file('image');
		if(!$file)
		{
			return $this->kerror('找不到图片');
		}
		$savename = \think\facade\Filesystem::putFile( 'upload', $file);
		if($savename)
		{
			
			$url=$this->site.'vttp/runtime/storage/'.str_replace('\\','/',$savename);
			$this->setobj($url);
		}
		else{
			return $this->kerror('接收图片失败');
		}
		
		return $this->ok();
		
    }
	
	
	 
	
}
